<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j" template="/layout/template.xhtml">

	<ui:define name="body">

		<h:form id="courseAddStudent">


			<h:panelGrid columns="1" width="%100">
				<s:decorate id="MilestoneName" template="/layout/edit.xhtml">
					<ui:define name="label">#{messages.milstoneName}</ui:define>
					<h:inputText value="#{activityHome.instance.name}" required="true" />
				</s:decorate>
				<s:decorate id="description" template="/layout/edit.xhtml">
					<ui:define name="label">#{messages['txt.activityDetails']}</ui:define>
					<h:inputTextarea value="#{activityHome.instance.desciption}"   style="width: 500px; height: 150px" required="true" />
				</s:decorate>
				
				<s:decorate id="dueDate" template="/layout/edit.xhtml">
					<ui:define name="label">#{messages['txt.dueDate']}</ui:define>
					<rich:calendar value="#{activityHome.instance.dueDate}"
						showApplyButton="false" cellWidth="24px" cellHeight="22px"
						style="width:200px" required="true" />
				</s:decorate>
				<s:decorate id="submissionField" template="/layout/edit.xhtml">
					<ui:define name="label">#{messages.allowSubmission}</ui:define>
					<h:selectBooleanCheckbox value="#{activityHome.submissionActivity}">
						<a4j:support event="onclick" reRender="reviewPanel,reviewPanels"
							ajaxSingle="true" />
					</h:selectBooleanCheckbox>
				</s:decorate>
				<a4j:outputPanel id="reviewPanel">
					<s:decorate id="announcementField2" template="/layout/edit.xhtml"
						rendered="#{activityHome.submissionActivity and scheduleHome.hasSubmissionActivities()}">
						<ui:define name="label">#{messages.allowReview}</ui:define>
						<h:selectBooleanCheckbox value="#{activityHome.reviewActivity}">
							<a4j:support event="onclick" reRender="reviewPanels"
								ajaxSingle="true" />
						</h:selectBooleanCheckbox>
					</s:decorate>
				</a4j:outputPanel>
			</h:panelGrid>

			<a4j:outputPanel id="reviewPanels">
				<h:panelGrid columns="1" width="50%">
					<rich:panel rendered="#{activityHome.reviewActivity}">
						<f:facet name="header">#{messages.reviewManagement}</f:facet>
						<h:panelGrid columns="1">


							<s:decorate id="submissionField2" template="/layout/edit.xhtml">
								<ui:define name="label">#{messages.activityToBeReviewed}</ui:define>
								<h:selectOneMenu id="combo2" defaultLabel=""
									value="#{activityHome.instance.reviewActivity}">
									<s:selectItems
										value="#{submissionActivityForCourse.resultList}"
										var="activit" label="#{activit.name}" itemLabel="#{activit.name}" hideNoSelectionLabel="false" 
											noSelectionLabel="#{messages.selectActivity}" />
									<s:convertEntity></s:convertEntity>
									<a4j:support event="onchange"
											ajaxSingle="true" />
								</h:selectOneMenu>
							</s:decorate>
							<a4j:outputPanel id="reviewPairs">
								<h:panelGrid columns="4" width="100%">
									<h:selectOneMenu id="combo0" defaultLabel=""
										value="#{activityHome.reviewer}" >
										<s:selectItems value="#{courseHome.instance.projectTeams}"
											var="activit" 
											label="#{activit.name}" 
											itemLabel="#{activit.name}" 
											hideNoSelectionLabel="false" 
											noSelectionLabel="#{messages.prteamnoselect}"/>
										<s:convertEntity></s:convertEntity>
										<a4j:support event="onchange"
											ajaxSingle="true" />
									</h:selectOneMenu>
									<h:outputText value="#{messages.reviews}" />
									<h:selectOneMenu id="combo1" defaultLabel=""
										value="#{activityHome.reviewee}">
										<s:selectItems value="#{courseHome.instance.projectTeams}"
											var="activit" label="#{activit.name}" hideNoSelectionLabel="false" noSelectionLabel="#{messages.prteamnoselect}"/>
										<s:convertEntity></s:convertEntity>
										<a4j:support event="onchange" bypassUpdates="false"
											ajaxSingle="true" />
									</h:selectOneMenu>

									<a4j:commandButton action="#{activityHome.addPair()}"
										value="#{messages.assign}" ajaxSingle="true" 
										reRender="reviewPairs"
										rendered="#{identity.hasRole('Instructor') or identity.hasRole('Teaching Assistant')}"/>

								</h:panelGrid>
								<a4j:outputPanel id="reviewTable">
									<rich:dataTable
										rendered="#{not empty activityHome.reviewPairs}"
										value="#{activityHome.reviewPairs}" var="pair">
										<h:column>
											<f:facet name="header">#{messages.Assignemnts}</f:facet>
											<h:outputText value="#{pair}" />
										</h:column>
										<h:column>
											<f:facet name="header">#{messages.Action}</f:facet>
											<a4j:commandButton action="#{activityHome.removePair(pair)}"
												value="#{messages.remove}" ajaxSingle="true"
												reRender="reviewTable"></a4j:commandButton>
										</h:column>
									</rich:dataTable>
								</a4j:outputPanel>
							</a4j:outputPanel>

						</h:panelGrid>
					</rich:panel>
				</h:panelGrid>
			</a4j:outputPanel>

			<div class="actionButtons">
				<h:commandButton id="save" value="Save"
					action="#{activityHome.persistWithCourse}"
					rendered="#{!activityHome.managed and (identity.hasRole('Instructor') or identity.hasRole('Teaching Assistant'))}" />
				<h:commandButton id="update" value="Save"
					action="#{activityHome.update}" rendered="#{activityHome.managed and (identity.hasRole('Instructor') or identity.hasRole('Teaching Assistant'))}" />
				<h:commandButton id="delete" value="Delete"
					action="#{activityHome.remove}" immediate="true"
					rendered="#{activityHome.managed} and (identity.hasRole('Instructor') or identity.hasRole('Teaching Assistant'))" />
				<s:button id="cancel" value="#{messages.Cancel}"
					view="/Course/course.xhtml">
				</s:button>
			</div>

		</h:form>

	</ui:define>

</ui:composition>